<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('系统响应时间统计记录（方便对响应时间长的进行优化）列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">

                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>类名：</p>
                                <input type="text" name="className"/>
                            </li>
                            <li>
                                <p>方法名：</p>
                                <input type="text" name="methodName"/>
                            </li>
                            <li>
                                <p>消耗时间：</p>
                                <input type="text" placeholder="大于（毫秒）" name="spendTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <div style="color: red;">
                    系统响应时间超过<span th:text="${CONDITION_TIME}"></span>毫秒时，后台方法将被记录！
                </div>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="monitor:time:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:time:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var removeFlag = [[${@permission.hasPermi('monitor:time:remove')}]];
        var prefix = ctx + "monitor/time";

        $(function() {
            var options = {
                url: prefix + "/list",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "系统响应时间统计记录（方便对响应时间长的进行优化）",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '主键',
                    visible: false
                },
                {
                    field : 'className', 
                    title : '类名'
                },
                {
                    field : 'methodName', 
                    title : '方法名'
                },
                {
                    field : 'spendTime', 
                    title : '消耗时间(毫秒)'
                },
                {
                    field: 'id',
                    title: '时间',
                    formatter: function (value, row, index) {
                        return convertTimeUuidToDateStr(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /*将后台返回的时间戳id转换成日期字符串*/
        function convertTimeUuidToDateStr(id){
            id = id+"";
            var year = "20"+id.substring(0,2);
            var month = id.substring(2,4);
            var day = id.substring(4,6);
            var hour = id.substring(6,8);
            var min = id.substring(8,10);
            var sec = id.substring(10,12);
            return	year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
        }
    </script>
</body>
</html>